package fangbing.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import fangbing.model.User;
import fangbing.service.UserService;

@Controller
public class LoginController {
	
	@Autowired
	private UserService userService;
	
	@RequestMapping("/login/loginCheck")
	public ModelAndView loginCheck(User user){
		
		ModelAndView modelAndView = null;
		
		//判断userName是否存在
		Map<String, Object> map = userService.searchUserByUserName(user);
		User userInfo = (User) map.get("user");
		//判断密码是否一致
		if(userInfo!=null&&user.getPassWord().equals(userInfo.getPassWord())){
			//存在用户且密码一致
			modelAndView = new ModelAndView("index");
		}else{
			
		}
		return modelAndView;
	}

}
